#include "User.h"
#include <ctime>
#include "Date.h"
#include "UserLogin.h"
#include "AdministorUI.h"
#include "LibrarianUI.h"
#include "StudentUI.h"
#include "TeacherUI.h"
#include "SeqList.h"
#include "Librarain.h"
#include "Student.h"
#include "Teacher.h"
#include "BorrowRecord.h"
#include "Book.h"
#include<fstream>
#include <string>
#include<iostream>
using namespace std;
int main()
{
    time_t nowtime;
    time(&nowtime);
	struct tm local;
	localtime_s(&local,&nowtime);
	int year=local.tm_year+1900;
	int month=local.tm_mon+1;
	int day=local.tm_mday;
	Date date(year,month,day);
	cout<<date.toString()<<endl;
	Date date1(date.toString());
    cout<<date1.toString()<<endl;
	Date date2("2014:7:1");
    cout<<date2.toString()<<endl;
    SeqList<Librarian> lib;
    lib.createList();
	lib.traverseList();
	lib.writeToFile("librarian.dat");
	lib.readFromFile("librarian.dat");
	lib.traverseList();

    SeqList<Student> stu;
    stu.createList();
	for(int i=0;i<stu.Length();i++)
		stu[i].setBorrowingCount(0);
	stu.traverseList();
	stu.writeToFile("student.dat");
	stu.readFromFile("student.dat");
	stu.traverseList();

    SeqList<Teacher> tea;
    tea.createList();
	tea.traverseList();
	tea.writeToFile("teacher.dat");
	tea.readFromFile("teacher.dat");
	tea.traverseList();

    SeqList<Book> book;
    book.createList();
	book.traverseList();
	book.writeToFile("book.dat");
	book.readFromFile("book.dat");
	book.traverseList();

	SeqList<BorrowRecord> br;
    br.createList();
	br.traverseList();
	br.writeToFile("borrowrecord.dat");
	br.readFromFile("borrowrecord.dat");
	br.traverseList();


	UserLogin ulogin;
    while(true)
	{

		ulogin.handlUserLogin();
		string userType=ulogin.GetUserType();
		string num=ulogin.GetUserNum();

		if (userType=="student")   StudentUI stuUI(num);

		if (userType=="teacher")   TeacherUI teaUI(num);

		if (userType=="librarian")	LibrarianUI libUI(num);

		if (userType=="administor")	AdministorUI adminUI;
	}

	system("pause");
	return 0;
}
